package com.bupt.liutong.front.sch.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.bupt.liutong.admin.core.base.BaseAction;
import com.bupt.liutong.admin.sch.bo.TeacherBo;
import com.bupt.liutong.admin.sch.bo.TeacherPhotoBo;
import com.bupt.liutong.admin.sch.form.TeacherForm;

public class TeacherAction extends BaseAction {

	private TeacherBo teacherBo;
	private TeacherPhotoBo teacherPhotoBo;
	
	public ActionForward list(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		TeacherForm teacherForm = (TeacherForm) form;
		teacherForm.setPageSize(7);
		request.setAttribute("teacherFormList", teacherBo.getTeachersByPageAtFront(teacherForm, request));
		putPageInfo(request, teacherForm);
		return mapping.findForward("list");
	}
	
	public ActionForward des(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		TeacherForm teacherForm = (TeacherForm) form;
		request.setAttribute("teacherForm", teacherBo.getTeacherById(teacherForm));
		request.setAttribute("photoFormList", teacherPhotoBo.getTeacherPhotos(teacherForm));
		return mapping.findForward("des");
	}

	public void setTeacherBo(TeacherBo teacherBo) {
		this.teacherBo = teacherBo;
	}
	
	public void setTeacherPhotoBo(TeacherPhotoBo teacherPhotoBo) {
		this.teacherPhotoBo = teacherPhotoBo;
	}
}
